# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=java-postgresql-jdbc
_pkgname=postgresql-jdbc
pkgver=42.6.0
pkgrel=1
pkgdesc="Java JDBC 4.2 (JRE 8+) driver for PostgreSQL database"
url="https://jdbc.postgresql.org/"
# riscv64 blocked by java-jdk
# aarch64: jdk segfaults building it
arch="noarch !aarch64 !riscv64"
license="BSD-3-Clause"
makedepends="java-jdk gradle"
source="$pkgname-$pkgver.tar.gz::https://github.com/pgjdbc/pgjdbc/archive/REL$pkgver.tar.gz
	increase-max-memory.patch
	"
options="!check net" # tests require running postgres server
builddir="$srcdir/pgjdbc-REL$pkgver"

# secfixes:
#   42.5.1-r0:
#     - CVE-2022-41946
#   42.4.2-r0:
#     - CVE-2022-31197
#   42.2.25-r0:
#     - CVE-2022-21724
#     - CVE-2020-13692

build() {
	# Note: Gradle downloads quite many dependencies, but
	# these are used only for building, not bundled to the final JAR.
	export JAVA_HOME="/usr/lib/jvm/default-jvm"
	gradle --no-daemon -p pgjdbc jar
}

check() {
	gradle --no-daemon -p pgjdbc test
}

package() {
	install -Dm644 ./pgjdbc/build/libs/postgresql-$pkgver-SNAPSHOT.jar \
		"$pkgdir"/usr/share/java/$_pkgname-$pkgver.jar
	ln -s $_pkgname-$pkgver.jar "$pkgdir"/usr/share/java/$_pkgname.jar
}

sha512sums="
e3e7bec0255a5d1cdbd82332a0dec1c518c5bc6caef91f6a4347e4653f5203bb252d8cc649ee66bc6aa00653536683818862be19a3fc0825186c93607affc8e1  java-postgresql-jdbc-42.6.0.tar.gz
5f761b43c5350e178e1f49e03625f01c61200033c220b93dded04069e96160d03bb7ca9ace9d733c7d14a9569d853772cc9df97e284da8e3daed4fcaf8313c8b  increase-max-memory.patch
"
